home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / util / virus / BBBF109p.lha / Programmers / BootblockLibrary.doc next >
Text File  |  1995-04-21  |  11KB  |  379 lines

  1.  
  2.                           Bootblock.library
  3.                              version 3.1
  4.                               3324 bytes
  5.  
  6.                    Released the 26th of June 1993
  7.  
  8.              Programmed by Johan Eliasson, SHI member.
  9.             Copyright © Safe Hex International 1992, 1993, 1994.
  10.  
  11.  
  12. INTRODUCTION
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14.  
  15. The Bootblock.library/brainfile is made by SHI to make life a little
  16. bit easier for programmers of anti-virus utilities, diskcopy programs,
  17. directory utilities, disk packers and for whoever who wants to check the
  18. bootblock of some device, and of course for you, the user, who are dead-
  19. tired of those %$£&%$& viruses...
  20.  
  21.  
  22. The library has some easy-to-use functions to read the brainfile, and to
  23. check a bootblock with it. The brainfile will be kept in memory for
  24. you by the library, so that more than one program can use it simultaneously.
  25. I know this doc is short, but take a look at my CheckDrive.c source
  26. and you will get it. If not, write me a letter!
  27.  
  28.  
  29. Each bootblock is identified with a checksum of four strategically chosen
  30. longwords.
  31.  
  32.  
  33. I have about 600+ non-virus-bootblocks that I check every new version
  34. of the brainfile with, and so far there has been no false alarms!
  35.  
  36.  
  37. Note that this is not a standard auto-doc file. It is typed by hand!
  38.  
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. LEGAL STUFF
  41. ~~~~~~~~~~~
  42. The BBBF package is freely distributable as long as all of its files are
  43. included in their original form without additions, deletions, or
  44. modifications of any kind, with the following exception:
  45. If your program uses the Bootblock.library/Bootblock.brainfile then they
  46. may be distributed along with it.
  47.  
  48.  
  49. If you use this library in your program you must give credit to SHI (like
  50. the note below) and the programmer in your documentation.
  51. The BBBF package may not be used in a commercial program without written
  52. permission by Safe Hex International.
  53.  
  54.  
  55. Only a nominal fee (maximum 6$) may be charged for the distribution of BBBF.
  56. This software is provided "AS IS" without warranty of any kind, either
  57. expressed or implied. By using the BBBF package, you agree to accept the
  58. entire risk as to the quality and performance of the program.
  59.  
  60.  
  61.  
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. TABLE OF CONTENTS
  64.  
  65. Bootblock.library/ReadBBBF
  66. Bootblock.library/FreeBBBF
  67. Bootblock.library/CheckBoot
  68. Bootblock.library/GetBBBFInfo
  69. Bootblock.library/ListBBBF
  70. Bootblock.library/ReadBoot
  71. Bootblock.library/WriteBoot
  72. Bootblock.library/InstallBoot
  73.  
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. Bootblock.library/ReadBBBF
  76.  
  77.   result = ReadBBBF(name);
  78.  
  79.   long     ReadBBBF(char *);
  80.                     A0
  81.  
  82.   DESCRIPTION
  83.     Will read the Bootblock.brainfile from name, and keep it in memory
  84.     for you until you FreeBBBF() it.
  85.  
  86.   INPUTS
  87.     name = "L:Bootblock.brainfile" or wherever you want to load it from.
  88.  
  89.   RESULT
  90.     result = errorcode.
  91.     if result >  0  then result is the code returned by IoErr() in case
  92.                     of an IO error.
  93.     if result =  0  then the brainfile is successfully loaded and
  94.                     everything's fine.
  95.     if result = -1  It was no brainfile...strange...
  96.                 -2  Corrupted brainfile. Someone has fiddled with it.
  97.                 -3  Already loaded by someone else!
  98.                 -4  No memory for brainfile. Free some and try again...
  99.  
  100.  
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. Bootblock.library/FreeBBBF
  103.  
  104.   result = FreeBBBF();
  105.  
  106.   void     FreeBBBF(void);
  107.  
  108.  
  109.   DESCRIPTION
  110.     Will free the memory used for the brainfile, ie. unload it.
  111.     If the brainfile is not loaded the function will just return.
  112.     You don't HAVE to do this. If you don't, it will be done when
  113.     the library is flushed.
  114.  
  115.   INPUTS
  116.     none
  117.  
  118.   RESULT
  119.     none
  120.  
  121. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. Bootblock.library/CheckBoot
  123.  
  124.   Boot = CheckBoot(buffer,&status);
  125.  
  126.   struct Bootblock *CheckBoot(char *,ULONG);
  127.                               A0     A1
  128.  
  129.   DESCRIPTION
  130.  
  131.   INPUTS
  132.     buffer = simply the bootblock that you want to check.
  133.     status = address of an ULONG. Status will afterwards contain one 
  134.              of the following values:
  135.              -1 : Error - The brainfile is not loaded.
  136.               0 : The bootblock is unknown.
  137.               1 : The bootblock is a virus! Kill it!
  138.               2 : The bootblock is not bootable...
  139.  
  140.   RESULT
  141.     Boot    Bootblock struct that contains the name of the bootblock etc.
  142.             If status != 1 then Boot will be NULL.
  143.  
  144.   NOTES
  145.     If the bootblock is a virus, then you'll have to append ' virus!' to
  146.     the name from the Bootblock struct. It saved me quite a lot of bytes
  147.     in the brainfile. 200 ' virus!' would be 1400 bytes...
  148.     I hope you don't mind! 8-)
  149.  
  150. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  151. Bootblock.library/GetBBBFInfo
  152.  
  153. result = GetBBBFInfo(&virus,version);
  154.  
  155. long     GetBBBFInfo(USHORT,char[30]);
  156.                      A0       A1
  157.  
  158.   DESCRIPTION
  159.  
  160.   INPUTS
  161.     virus   = will be the number of viruses known to this brainfile.
  162.     version = string that will contain the brainfile version-string,
  163.               without the '$VER: '.
  164.  
  165.   RESULT
  166.    result   If result == -1 then the brainfile is not loaded.
  167.             If success then result will be 0.
  168.  
  169.  
  170. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  171. Bootblock.library/ListBBBF
  172.  
  173. Boot = ListBBBF()
  174.  
  175. struct Bootblock *ListBBBF(void)
  176.  
  177.   DESCRIPTION
  178.     This function returns the pointer to the first Bootblock structure.
  179.     Useful for listing all known bootblocks etc.
  180.  
  181.   INPUTS
  182.     none
  183.  
  184.   RESULT
  185.     Boot   Pointer to the first Bootblock structure, or
  186.            NULL == the brainfile is not loaded.
  187.  
  188. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189. Bootblock.library/ReadBoot
  190.  
  191. result = ReadBoot(drive,buffer);
  192.  
  193. ULONG    ReadBoot(ULONG,char *);
  194.                   D0    A0
  195.  
  196.   DESCRIPTION
  197.  
  198.     This function will read the bootblock from the desired drive,
  199.     using the trackdisk.device and CMD_READ.
  200.  
  201.   INPUTS
  202.  
  203.     drive  = drive number (0-3)
  204.  
  205.     buffer = the destination of the bootblock. Must be at least 1024
  206.              bytes. Note that it must be in chip ram if running
  207.              under kickstart V36 or below.
  208.  
  209.   RESULT
  210.  
  211.     result = either NULL = success,
  212.              or an errorcode returned by IoErr(),
  213.              Can occur during the OpenDevice() (see <exec/errors.h>
  214.              or the bootread (see <devices/trackdisk.h>)
  215.              It can also be 103 (out of memory).
  216.  
  217. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  218. Bootblock.library/WriteBoot
  219.  
  220. result = WriteBoot(drive,buffer);
  221.  
  222. ULONG    WriteBoot(ULONG,char *);
  223.                   D0    A0
  224.  
  225.   DESCRIPTION
  226.  
  227.     This function will write the bootblock to the selected drive.
  228.  
  229.   INPUTS
  230.  
  231.     drive  = drive number (0-3)
  232.  
  233.     buffer = the bootblock. Note that it must be in chip ram if running
  234.              under kickstart V36 or below.
  235.  
  236.   RESULT
  237.  
  238.     result = either NULL = success,
  239.              or an errorcode returned by IoErr(),
  240.              Can occur during the OpenDevice() (see <exec/errors.h>
  241.              or the bootwrite (see <devices/trackdisk.h>)
  242.              It can also be 103 (out of memory).
  243.  
  244. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  245. Bootblock.library/InstallBoot
  246.  
  247. result = InstallBoot(drive,bootnumber);
  248.  
  249. long   = InstallBoot(ULONG,USHORT)
  250.                      D0    D1
  251.  
  252.   DESCRIPTION
  253.  
  254.     This function will install an AmigaDOS bootblock to the selected drive.
  255.  
  256.   INPUTS
  257.  
  258.     drive : drive number (0-3)
  259.  
  260.     bootnumber : 0 = 1.x OFS
  261.                  1 = 1.3 FFS
  262.                  2 = 2.0 OFS
  263.                  3 = 2.0 FFS
  264.                  4 = 2.0 OFS International
  265.                  5 = 2.0 FFS International
  266.                  6 = 3.0 OFS DirCache
  267.                  7 = 3.0 FFS DirCache
  268.  
  269.   RESULT
  270.  
  271.     result : either NULL = success,
  272.              or an errorcode returned by IoErr(),
  273.              Can occur during the OpenDevice() (see <exec/errors.h>
  274.              or the bootwrite (see <devices/trackdisk.h>)
  275.              It can also be 103 (out of memory),
  276.              or -99 = illegal bootnumber (must be 0 - 7).
  277.  
  278. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  279.  
  280. LIBRARY HISTORY
  281. ~~~~~~~~~~~~~~~
  282.  
  283. Version 0.9 beta
  284. ~~~~~~~~~~~~~~~~
  285. First version.
  286.  
  287. Version 0.91 beta
  288. ~~~~~~~~~~~~~~~~~
  289. Removed all non-virus bootblocks from the brainfile upon request from
  290. Erik Loevendahl Soerensen. Now you will only be alerted if the bootblock
  291. contains a virus, anti-virus, or any other suspicious resident program.
  292. This is for speed and so that the user won't be bothered with messages
  293. like 'This bootblock is the MegaSuperDemoLoader 32.84' all the time.
  294. The GetBBBFInfo() function is changed accordingly.
  295.  
  296.  
  297. I have tried to clean up this doc a bit too. There were a few obvious
  298. mistakes that I guess you spotted.
  299. BBBF now knows 171 original viruses, and a vast number of clones.
  300.  
  301.  
  302. Version 0.92 beta (15.10.92)
  303. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  304. V 0.91 didn't recognize the Chameleon (little Sven) virus correctly.
  305. Instead of adding a short piece of code to deal with that, I rewrote
  306. the complete brainfile-system, so it will be easier to add new viruses
  307. to the brainfile from now on. As a result of that, the Bootblock structure
  308. has changed a bit. Also, ReadBBBF() and CheckBoot() are a little bit slower,
  309. and the brainfile is 656 bytes bigger......but a lot safer!
  310. BBBF now knows 164 original viruses, and a vast number + 7 clones.
  311.  
  312.  
  313. Version 0.93 beta (05.11.92)
  314. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315. Bug fix: If the brainfile-reading was interrupted due to lack of memory,
  316.          the already allocated memory would not be freed correctly. 
  317.  
  318.  
  319. Version 1.0 (11.11.92)
  320. ~~~~~~~~~~~~~~~~~~~~~~
  321. New function - ReadBoot().
  322. I also optimized the library down to 2876 bytes!
  323.  
  324.  
  325. Version 1.01 (12.12.92)
  326. ~~~~~~~~~~~~~~~~~~~~~~~
  327. Now you don't HAVE to free the memory with FreeBBBF() when you exit.
  328. If you don't, it will be freed automagically when the library is flushed.
  329.  
  330.  
  331. Version 2.00 (16.12.92)
  332. ~~~~~~~~~~~~~~~~~~~~~~~
  333. New function - WriteBoot().
  334.  
  335. I learned that OpenLibrary() is case-sensitive. And I have spelled
  336. Bootblock.library with a capital B... so if your OpenLibrary() fails,
  337. that might be the cause...
  338.  
  339.  
  340. Version 3.00 (02.03.93)
  341. ~~~~~~~~~~~~~~~~~~~~~~~
  342. New function - InstallBoot()
  343.  
  344.  
  345. Version 3.1 (26.06.93)
  346. ~~~~~~~~~~~~~~~~~~~~~~
  347. Corrected the version-string as you can see.
  348. Changed a few other internal things.
  349.  
  350.  
  351. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352.  
  353. Please, SHI need your opinions! Even if you have no complaints nor ideas
  354. it's nice just to hear that it works... 8-)
  355. Send new viruses, ideas, threats and harddrives to:
  356.  
  357.  
  358.  
  359.         SHI MAIN CENTRAL VIRUS CENTRE:
  360.         -----------------------------
  361.         Erik Loevendahl Soerensen
  362.         Snaphanevej 10
  363.         DK-4720 Praestoe 
  364.         Denmark
  365.  
  366.         Phone   : +45 55 992512
  367.         Fax     : +45 55 993498
  368.         Fidonet : 2:236/116.17
  369.         Amiganet: 39:141/127.17
  370.  
  371.  
  372. Thanks goes to Magnus Holmgren and Tommy Hallgren for helping out with my
  373. C problems, Tommy Hallgren and Mats Erlandsson for testing!
  374. Erik Loevendahl Soerensen at SHI for all his support.
  375. John Lohmeyer, whose Interpret.library I used as a model when designing
  376. this library. Thanks guys!
  377.  
  378. END OF DOC.
  379.